]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
mixer-control: Always update port list
authorGuido Günther <agx@sigxcpu.org>
Sun, 4 Jan 2026 12:07:27 +0000 (13:07 +0100)
committerSimon McVittie <smcv@debian.org>
Wed, 28 Jan 2026 13:25:18 +0000 (13:25 +0000)
It can change underneath us, see

  https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/5053

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Origin: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/merge_requests/31
Bug: https://gitlab.gnome.org/GNOME/libgnome-volume-control/-/issues/34
Bug-Debian: https://bugs.debian.org/1126514
Applied-upstream: gnome-shell 50, commit:798230599950607ec285daecd070f5bcb28580e4

Gbp-Pq: Topic libgvc
Gbp-Pq: Name mixer-control-Always-update-port-list.patch

subprojects/gvc/gvc-mixer-control.c

index e5b6ca96965b42a8bf13ca24d57de8225c6baf06..a6aaf2e2877f7c275a798c0317e98961698536c3 100644 (file)
@@ -1451,6 +1451,7 @@ update_sink (GvcMixerControl    *control,
         pa_volume_t     max_volume;
         GvcChannelMap   *map;
         char            map_buff[PA_CHANNEL_MAP_SNPRINT_MAX];
+        GList          *list = NULL;
 
         pa_channel_map_snprint (map_buff, PA_CHANNEL_MAP_SNPRINT_MAX, &info->channel_map);
 #if 1
@@ -1467,27 +1468,10 @@ update_sink (GvcMixerControl    *control,
                                       GUINT_TO_POINTER (info->index));
 
         if (stream == NULL) {
-                GList *list = NULL;
-                guint i;
-
                 map = gvc_channel_map_new_from_pa_channel_map (&info->channel_map);
                 stream = gvc_mixer_sink_new (control->priv->pa_context,
                                              info->index,
                                              map);
-
-                for (i = 0; i < info->n_ports; i++) {
-                        GvcMixerStreamPort *port;
-
-                        port = g_slice_new0 (GvcMixerStreamPort);
-                        port->port = g_strdup (info->ports[i]->name);
-                        port->human_port = g_strdup (info->ports[i]->description);
-                        port->priority = info->ports[i]->priority;
-                        port->available = info->ports[i]->available != PA_PORT_AVAILABLE_NO;
-
-                        list = g_list_prepend (list, port);
-                }
-                gvc_mixer_stream_set_ports (stream, list);
-
                 g_object_unref (map);
                 is_new = TRUE;
 
@@ -1497,6 +1481,19 @@ update_sink (GvcMixerControl    *control,
                 return;
         }
 
+        for (guint i = 0; i < info->n_ports; i++) {
+                GvcMixerStreamPort *port;
+
+                port = g_slice_new0 (GvcMixerStreamPort);
+                port->port = g_strdup (info->ports[i]->name);
+                port->human_port = g_strdup (info->ports[i]->description);
+                port->priority = info->ports[i]->priority;
+                port->available = info->ports[i]->available != PA_PORT_AVAILABLE_NO;
+
+                list = g_list_prepend (list, port);
+        }
+        gvc_mixer_stream_set_ports (stream, g_steal_pointer (&list));
+
         max_volume = pa_cvolume_max (&info->volume);
         gvc_mixer_stream_set_name (stream, info->name);
         gvc_mixer_stream_set_card_index (stream, info->card);
@@ -1584,6 +1581,7 @@ update_source (GvcMixerControl      *control,
         GvcMixerStream *stream;
         gboolean        is_new;
         pa_volume_t     max_volume;
+        GList          *list = NULL;
 
 #if 1
         g_debug ("Updating source: index=%u name='%s' description='%s'",
@@ -1602,26 +1600,12 @@ update_source (GvcMixerControl      *control,
         stream = g_hash_table_lookup (control->priv->sources,
                                       GUINT_TO_POINTER (info->index));
         if (stream == NULL) {
-                GList *list = NULL;
-                guint i;
                 GvcChannelMap *map;
 
                 map = gvc_channel_map_new_from_pa_channel_map (&info->channel_map);
                 stream = gvc_mixer_source_new (control->priv->pa_context,
                                                info->index,
                                                map);
-
-                for (i = 0; i < info->n_ports; i++) {
-                        GvcMixerStreamPort *port;
-
-                        port = g_slice_new0 (GvcMixerStreamPort);
-                        port->port = g_strdup (info->ports[i]->name);
-                        port->human_port = g_strdup (info->ports[i]->description);
-                        port->priority = info->ports[i]->priority;
-                        list = g_list_prepend (list, port);
-                }
-                gvc_mixer_stream_set_ports (stream, list);
-
                 g_object_unref (map);
                 is_new = TRUE;
         } else if (gvc_mixer_stream_is_running (stream)) {
@@ -1630,6 +1614,17 @@ update_source (GvcMixerControl      *control,
                 return;
         }
 
+        for (guint i = 0; i < info->n_ports; i++) {
+                GvcMixerStreamPort *port;
+
+                port = g_slice_new0 (GvcMixerStreamPort);
+                port->port = g_strdup (info->ports[i]->name);
+                port->human_port = g_strdup (info->ports[i]->description);
+                port->priority = info->ports[i]->priority;
+                list = g_list_prepend (list, port);
+        }
+        gvc_mixer_stream_set_ports (stream, list);
+
         max_volume = pa_cvolume_max (&info->volume);
 
         gvc_mixer_stream_set_name (stream, info->name);